package rpg.engine.model;

import java.util.ArrayList;
import java.util.List;

import rpg.util.Strings;

public class GameMap {
	public static class Builder {
		private String name = "";
		
		public Builder name(String s)  {
			name = Strings.trim(s);
			return this;
		}
		
		public GameMap build()  {
			return new GameMap(this);
		}

		private String id = "";
		public Builder id(String s) {
			id = s;
			return this;
		}

		private final List<Mover> movers = new ArrayList<Mover>();
		public Builder mover(Mover m)  {
			movers.add(m);
			return this;
		}
		
		private List<String> rows = new ArrayList<String>();
		public Builder row(String line)  {
			rows.add(Strings.trim(line));
			return this;
		}
	}

	private final String name;
	
	public GameMap(Builder builder) {
		super();
		id = Strings.requireNonEmpty(builder.id, "GameMap.id");
		name = Strings.requireNonEmpty(builder.name, "GameMap.name");
		rows.addAll(builder.rows);
		movers.addAll(builder.movers);
	}

	public String getName()  {
		return name;
	}
	
	@Override
	public String toString()  {
		return "GameMap: " + getName();
	}

	private final String id;
	public String getId() {
		return id;
	}

	private final List<String> rows = new ArrayList<String>();
	
	public List<String> getRows() {
		return rows;
	}
	
	private final List<Mover> movers = new ArrayList<Mover>();
	public List<Mover> getMovers()  {
		return movers;
	}
}
